<?php
namespace app\sisome\controller;
use think\Controller;
class Shop extends Common {
	public function ly_list() {			//KM++留言列表
		$User = db( 'message' ); // 實例化User對象
		if(input('user')==''){
			$map['zt']='0';
		}else{
			$map['userName']=input('user');
		}
		
		if(input('type')=='0'){
			$map['zt']='0';
		}elseif(input('type')=='1'){
			$map['zt']='1';
		}
	
		$list = $User->where ( $map )->order ( 'ID DESC' )->paginate(100);
		// dump($User->getLastSql());die;
		// dump($list);die;
		$this->assign ( 'lists', $list ); // 賦值數據集
		// $userData = db ( 'user' )->where ( array (
		// 		'UE_ID' => $_SESSION ['uid']
		// ) )->find ();
		// $this->userData = $userData;
		return view();
	}
	public function ly_list_cl() {		//KM++留言回复-display
		$caution = db ( 'message' )->where ( array (
				'id'=> input('id') ,
		) )->find ();

		$this->assign ( 'caution', $caution ); 
			
		return view();
	}
	public function ly_list_xgcl2() {	//KM++留言回复-处理
		
			$data['reply']=$_POST['content'];
			$data['replytime']=date ( 'Y-m-d H:i:s', time () );
			$data['zt']='1';

			if(db('message')->where(array('id'=>input('id')))->update($data)){
				$this->success('处理成功！','shop/ly_list');
			}else{
				$this->success('处理失敗！');
			}
	}
	public function ly_list_del() {		//KM++留言删除

		$caution = db ( 'message' )->where ( array (
				'ID'=> input('id') ,
		) )->delete();
	
		if($caution){$this->success('刪除成功!');}else{$this->error('刪除失敗!');}
	}
	public function zsbyg_list() {		//KM++帮助中心列表
		$User = db ( 'info' ); // 實例化User對象
		
		if(input('type')==''){
			$map['zt']='0';
		}else{
			$map['IF_type']=input('type');
		}

		$count = $User->where ( $map )->count (); // 查詢滿足要求的總記錄數
		//$page = new \Think\Page ( $count, 3 ); // 實例化分頁類 傳入總記錄數和每頁顯示的記錄數(25)
		
		$p = getpage($count,100);
		
		$list = $User->where ( $map )->order ( 'IF_ID DESC' )->limit ( $p->firstRow, $p->listRows )->select ();
		$this->assign ( 'list', $list ); // 賦值數據集
		$this->assign ( 'page', $p->show() ); // 賦值分頁輸出
		$userData = db ( 'user' )->where ( array (
				'UE_ID' => $_SESSION ['uid']
		) )->find ();
		$this->userData = $userData;
	
		$this->display ( 'index/zsbyg_list' );
	}
	public function zsbyg_list_xg() {	//KM++帮助中心-文章添加-display
		$userData = db ( 'user' )->where ( array (
				'UE_ID' => $_SESSION ['uid']
		) )->find ();
		$this->userData = $userData;
	
		$this->display ( 'index/zsbyg_list_xg' );
	}
	public function jbzg_list_xgcl() {	//KM++帮助中心-文章添加-提交
		if(input('IF_theme')<>''&&$_POST['content']<>''){

			$data['IF_type']=input('IF_type');
			$data['IF_theme']=input('IF_theme');
			$data['IF_type1ID']=input('IF_type1ID');
			$data['IF_content']=$_POST['content'];
			$data['IF_time']=date ( 'Y-m-d H:i:s', time () );
			
			$data['enIF_theme'] = input('enIF_theme');
			$data['enIF_content']=$_POST['encontent'];
		
			if(M('info')->add($data)){
				$this->success('添加成功！');
			}else{
				$this->success('添加失敗！');
			}
		}else{
			$this->success('数据不完整！');
		}
	}
	public function zsbyg_list_xg2() {	//KM++帮助中心-文章修改-display
		$caution = db ( 'info' )->where ( array (
				'IF_ID'=> input('id') ,
		) )->find ();
	
	
		$this->caution=$caution;

	
		$userData = db ( 'user' )->where ( array (
				'UE_ID' => $_SESSION ['uid']
		) )->find ();
		$this->userData = $userData;
	
		$this->display ( 'index/zsbyg_list_xg2' );
	}
	public function jbzg_list_xgcl2() {	//KM++帮助中心-文章修改-提交
		if(input('IF_theme')<>''&&$_POST['content']<>''){
			$data['IF_type']=input('IF_type');
			$data['IF_theme']=input('IF_theme');
			$data['IF_type1ID']=input('IF_type1ID');
			$data['IF_content']=$_POST['content'];
			$data['enIF_theme'] = input('enIF_theme');
			$data['enIF_content'] = $_POST['encontent'];
			$data['IF_time']=date ( 'Y-m-d H:i:s', time () );
	
			if(M('info')->where(array('IF_ID'=>input('id')))->save($data)){
				$this->success('修改成功！');
			}else{
				$this->success('修改失敗！');
			}
			//$this->success('成功！');
		}else{
			$this->success('数据不完整！');
		}
	}
	public function zsbyg_list_del() {	//KM++帮助中心-文章删除
		$caution = db ( 'info' )->where ( array (
				'IF_ID'=> input('id') ,
		) )->delete();
		if($caution){$this->success('刪除成功!');}else{$this->error('刪除失敗!');}
	}
	
}